package com.edu.edumanager.controller;

import com.edu.edumanager.bean.EduChapter;
import com.edu.edumanager.bean.EduVideo;
import com.edu.edumanager.service.VideoService;
import com.edu.edumanager.vo.EduChapterList;
import com.edu.edumanager.vo.EduResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @program: edu-manager
 * @description:
 * @author: Jaime
 * @create: 2021-08-22 20:30
 **/
@RestController
@CrossOrigin
@RequestMapping("/eduservice/video")
public class EduVideoController {
    @Autowired
    VideoService videoService;
    /**
     * 上传用户头像
     *
     * @param file
     * @return
     */
    @RequestMapping("/uploadVideo")
    public EduResult uploadVideo(MultipartFile file) {
        EduResult result = videoService.uploadVideo(file);
        return result;
    };

    /**
     * 根据videoId 删除video
     *
     * @param
     * @return 结果集
     */
    @RequestMapping("/deleteVideo/{videoId}")
    public EduResult deleteVideoById(@PathVariable Integer videoId){
        int count = videoService.deleteVideoById(videoId);
        return EduResult.ok();
    }

    @RequestMapping("/getVideo/{videoId}")
    public EduResult getVideo(@PathVariable Integer videoId){
        EduVideo video = videoService.getVideo(videoId);
        return EduResult.ok().data("video",video);
    };
    @RequestMapping("/updateVideo")
    public EduResult updateVideo(@RequestBody EduVideo video){
        System.out.println(video);
        int count = videoService.updateVideo(video);
        return EduResult.ok().data("count",count);
    }

}
